//
//  TWCorrelationModel.swift
//  EyepetizerImitative
//
//  Created by 田伟 on 2017/3/24.
//  Copyright © 2017年 个人. All rights reserved.
//  相关页面的列表cell的model

import UIKit

class TWCorrelationModel: NSObject {

    // MARK:- 属性
    var count : NSNumber?
    var dataType : String?
    var header : CorrelationHeaderModel?
    var itemList : [[String : AnyObject]]?{
        didSet {
            guard let itemList = itemList else {
                return
            }
            for item in itemList {
                let itemModel = TWItemModel(dict: item["data"] as! [String : AnyObject])
                correlationitemList.append(itemModel)
            }
        }
    }
    var type : String?
    
    var correlationitemList = [TWItemModel]()
    
    // MARK:- 转成字典——自定义构造函数
    init(dict : [String : AnyObject]) {
        super.init()
        setValuesForKeys(dict)
        // 将第二层字典转模型
        if let dict = dict["header"] as? [String : AnyObject] {
            header = CorrelationHeaderModel(dict : dict)
        }
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {}
}

// MARK:- header属性
class CorrelationHeaderModel: NSObject {
    
    var actionUrl : String?
    var font : String?
    var tw_id : NSNumber?
    var title : String?
    
    init(dict : [String : AnyObject]) {
        super.init()
        tw_id = dict["id"] as! NSNumber?
        setValuesForKeys(dict)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {}
}
